package com.ophiux.util;

import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



public class PropertyUtil {
	
	private final static String PROPERTY_FILE_NAME = "ophiux";
	
	
	private static Logger logger = LoggerFactory.getLogger(PropertyUtil.class);

	private static Map<String, String> proMap = new HashMap<String, String>();
   
    
    private static  ResourceBundle res;
    
    static {
    	 res = ResourceBundle.getBundle(PROPERTY_FILE_NAME);
    }
    
    
	/**
	 * 
	 * Description: 根据参数获得值
	 * @param property
	 * @return
	 */
	private static String getPpoperty(String property){
       // 读取配置文件
		String value = res.getString(property);
		logger.info("读取配置文件{}信息属性 {}：{}",new Object[]{PROPERTY_FILE_NAME,property,value});
		return value;
	}
	
	/**
	 * 
	 * Description: 根据属性获得配置文件（emr_cfg）值
	 * @param property 属性
	 * @return
	 */
	public static String getResValue(String property){

		if(proMap.containsKey(property)){
			return proMap.get(property);
		}else{
			String value = getPpoperty(property);
			proMap.put(property, value);
			return value;
		}
	}

}
